<div class="films view">
<h2><?php  echo __('Film');?></h2>
	<div class="imagenFilm">
			<?php echo $this->Html->image($film['Film']['Image'],array('alt' => 'No se encuentra la imagen', 'url' => '/films/view/'.$film["Film"]["id"], 'class' =>'imagen')); ?>
			<?php echo $this->Ajax->Form(array('type' => 'post','options'=>array('url'=>'/films/calificar/'.$film['Film']['id'],'complete' => 'calificacion(request.responseText)')));
			       // echo $this->Form->create(array('type' => 'post','url'=>'/films/calificar'));
					echo $this->Form->hidden('calificacion',array('id'=>'calif','value'=>'0'));
				  for($i=0;$i<10 ;$i++)
						if($i%2==0)
							echo $this->Html->image('HalfStarGrayLeft.png',array('id' => 'calif'.$i,'class'=>'estrella')); 
						else
							echo $this->Html->image('HalfStarGrayRight.png',array('id' => 'calif'.$i,'class'=>'estrella'));  
				  echo $this->Ajax->Form->end('calificar');?>
			
				
	</div>
	<div class="detallesFilm">
		<dl>
			<dt><?php echo __('Title'); ?></dt>
			<dd>
				<?php echo h($film['Film']['title']); ?>
				&nbsp;
			</dd>
			<dt><?php echo __('Synopsis'); ?></dt>
			<dd>
				<?php echo h($film['Film']['synopsis']); ?>
				&nbsp;
			</dd>
			<dt><?php echo __('Release Date'); ?></dt>
			<dd>
				<?php echo h($film['Film']['release_date']); ?>
				&nbsp;
			</dd>
			<dt><?php echo __('Duration'); ?></dt>
			<dd>
				<?php echo h($film['Film']['duration']); ?>
				&nbsp;min
			</dd>
			<dt><?php echo __('Calification'); ?></dt>
			<dd>
				<?php 
					$calification=$film['Film']['cant_votantes']==0?0:(int)($film['Film']['calificacion_total']/$film['Film']['cant_votantes']);
					for($i=0;$i<$calification; $i++)
						if($i%2==0)
							echo $this->Html->image('HalfStarLeft.png',array('id' => 'c'.$i));  
						else
							echo $this->Html->image('HalfStarRight.png',array('id' => 'c'.$i));   		
					for($i=$calification;$i<10 ;$i++)
						if($i%2==0)
							echo $this->Html->image('HalfStarGrayLeft.png',array('id' => 'c'.$i));  
						else
							echo $this->Html->image('HalfStarGrayRight.png',array('id' => 'c'.$i));  
				?>
				&nbsp;
			</dd>
			<dt><?php echo __('Genres'); ?></dt>
			<dd>
				<ul class="lista">
				<?php
					foreach ($film['Genre'] as $genre): ?>
						<li><?php echo $genre['name'];?></li>
				<?php endforeach; ?>
				&nbsp;
				</ul>
				
			</dd>
			<dt><?php echo __('Actors'); ?></dt>
			<dd>
				<ul class="lista">
				<?php
					if(empty($film['Actor']))
						echo '&nbsp;';
					foreach ($film['Actor'] as $actor): ?>
						<li><?php echo $this->Html->Link($actor['name'],array('controller'=>'actors','action'=>'view',$actor['id']));?></li>
				<?php endforeach; ?>
				</ul>
							
			</dd>
			<dt><?php echo __('Directors'); ?></dt>
			<dd>
				<ul class="lista">
				<?php
					if(empty($film['Director']))
						echo '&nbsp;';
					foreach ($film['Director'] as $director): ?>
						<li><?php echo $this->Html->Link($director['name'],array('controller'=>'directors','action'=>'view',$director['id']));?></li>
				<?php endforeach; ?>
				</ul>
			</dd>
			<dt><?php echo __('Tags'); ?></dt>
			<dd>
				<ul class="lista">
				<?php
					if(empty($film['Tag']))
						echo '&nbsp;';
					foreach ($film['Tag'] as $tag): ?>
						<li><?php echo $tag['tag'];?></li>
				<?php endforeach; ?>
				</ul>
			</dd>
			<dt><?php echo __('Related films'); ?></dt>
			<dd>
				<?php
					foreach ($film['RFilm'] as $f){
						echo '<li>'.$this->Html->Link($f['title'],array('controller'=>'films','action'=>'view',$f['id'])).'</li>';
					}
						
					if(!empty($related))
					foreach ($related as $f): 
						if($f['exist']){
							 echo '<li>'.$this->Html->Link($f['title'],array('controller'=>'films','action'=>'view',$f['id'])).'</li>';
						}
						else
							echo '<li>'.$this->Html->Link($f['title'],array('controller'=>'WebService','action'=>'view',$f['id'])).'</li>';
				 endforeach; ?>
				&nbsp;
			</dd>
			
		</dl>
	</div>
	
	<div id="fb-root"></div>
	<script type="text/javascript">
		window.fbAsyncInit = function() {
			FB.init({
				status     : true, // check login status
				cookie     : true, // enable cookies to allow the server to access the session
				xfbml      : true  // parse XFBML
			});
		};	
		// Load the SDK Asynchronously
		(function(d){
			var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
			if (d.getElementById(id)) {return;}
			js = d.createElement('script'); js.id = id; js.async = true;
			js.src = "//connect.facebook.net/es_LA/all.js";
			ref.parentNode.insertBefore(js, ref);
		}(document));
	</script>
	<fb:like send="false" width="650" show_faces="true" colorscheme="dark"></fb:like>
	<?php
		$url ="http://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		$url= str_replace('&',"&amp;",$url);
	?>
	<div class="fb-comments" data-href="<?php echo $url;?>" data-num-posts="2" data-width="650" data-colorscheme="dark"></div>
	
</div>


